﻿@model CQIE.OVS.Web.Models.CamModel

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Edit</title>
    <link href="~/kj/layui/css/layui.css" rel="stylesheet" />
    <link href="~/kj/layui/css/Mylabel.css" rel="stylesheet" />
    <style type="text/css">
        .color {
            color: #01AAED;
        }
    </style>
</head>
<body style="width: 400px;margin-top: 10px;margin-left: 44px;">
    <script src="~/Scripts/jquery-3.3.1.min.js"></script>
    <script src="~/Scripts/jquery.validate.min.js"></script>
    <script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>

<form class="layui-form" action="#" method="post">
    @Html.AntiForgeryToken()

    <div class="form-horizontal">
        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
        @Html.HiddenFor(model => model.Id)
        @Html.HiddenFor(model=>model.ActiveId)
        <div class="layui-form-item">
            <label class="mylabel color">姓名:</label>
            <div class="layui-col-md7">
                @Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "layui-input" } })
                @Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="layui-form-item">
            <label class="mylabel color">简介:</label>
            <div class="layui-col-md7">
                @Html.TextAreaFor(model => model.Info,  new { @class = "layui-textarea" } )
                @Html.ValidationMessageFor(model => model.Info, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="layui-form-item">
            <label class="mylabel color">性别:</label><br/>
            <div class="layui-col-md7">
                @{
                    if (Model.Sex == "男")
                    {
                        <input type="radio" name="sex" value="男" title="男" checked>
                        <input type="radio" name="sex" value="女" title="女">
                    }
                    else
                    {
                        <input type="radio" name="sex" value="男" title="男">
                        <input type="radio" name="sex" value="女" title="女" checked>
                    }
                }
            </div>
        </div>

        <div class="layui-form-item">
            <label class="mylabel color">年龄:</label>
            <div class="layui-col-md7">
                @Html.EditorFor(model => model.Age, new { htmlAttributes = new { @class = "layui-input" } })
                @Html.ValidationMessageFor(model => model.Age, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="layui-form-item layui-col-md4 layui-col-md-offset1">
            <div class="layui-input-line">
                <button class="layui-btn" type="submit" lay-submit lay-filter="formDemo">立即保存</button>
            </div>
        </div>
    </div>
</form>

    <script src="~/kj/layui/layui.js"></script>
<script>
    layui.use(['jquery', 'layer','form'],
        function() {
            var $ = layui.jquery;
            var layer = layui.layer;
            var form = layui.form;

            form.render();

            form.on('submit(formDemo)', function (data) {
                
                model = {
                    'Id':$('#Id').val(),
                    'Name': $('#Name').val(),
                    'Age': $('#Age').val(),
                    'Sex': $('input[name = sex]:checked').val(),
                    'Info': $('#Info').val(),
                    'ActiveId':$('#ActiveId').val()
                };
                console.log(model.Sex);
                $.post('/Cam/EditCam', { Camdata: model }, function() {
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                });
                layer.msg('修改成功！');                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
                return false;
            });

        });

</script>
</body>
</html>
